﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MemoryVerse;

namespace WFWorshipManager
{
    public partial class Quiz : Form
    {
        VerseLibrary VL = LibraryManager.LoadLibrary();
        Verse myVerse;
        int phrasecount = 0;
       
        public Quiz()
        {
            Random ran = new Random();
            InitializeComponent();
            //myVerse = VL.VerseList[ran.Next(VL.VerseList.Count - 1)];
            myVerse = VL.VerseList[3];
            label1.Text = myVerse.Book.ToString() + " " + myVerse.Chapter + ":" + myVerse.StartVerse + "-" + myVerse.EndVerse;
            lbFullText.Text = myVerse.Text;
        }

        public Quiz( int QuizToLoad)
        {
            Random ran = new Random();
            InitializeComponent();
            //myVerse = VL.VerseList[ran.Next(VL.VerseList.Count - 1)];
            myVerse = VL.VerseList[QuizToLoad];
            label1.Text = myVerse.Book.ToString() + " " + myVerse.Chapter + ":" + myVerse.StartVerse + "-" + myVerse.EndVerse;
            lbFullText.Text = myVerse.Text;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (myVerse.Phrases.Count > phrasecount)
            {
                textBox1.Text = textBox1.Text + myVerse.Phrases[phrasecount].Phrase;
                phrasecount++;
            }
        }

        private void rtbVerse_TextChanged(object sender, EventArgs e)
        {
            rtbVerse.BackColor = Color.White;
            int index = 0;
            foreach (char b in rtbVerse.Text)
            {
                if (lbFullText.Text.Length >  index) // did i type more characters than the answer has?
                {
                    if (lbFullText.Text[index] != b)
                    {
                        rtbVerse.BackColor = Color.PaleVioletRed;
                    }
                }
                index++;
            }

            if (lbFullText.Text == rtbVerse.Text)
            {
                rtbVerse.BackColor = Color.Honeydew;
                rtbVerse.ReadOnly = true;
            }
   
        }
    }
}
